package com.gzck.gzck_verson2.controller;


import com.gzck.gzck_verson2.pojo.GProjectIndustryInfo;
import com.gzck.gzck_verson2.service.IGProjectIndustryInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 行业表 前端控制器
 * </p>
 *
 * @author 任永辉
 * @since 2024-01-06
 */
@RestController
@RequestMapping("/gpii")
@CrossOrigin(origins = "*")
public class GProjectIndustryInfoController {

    @Autowired
    private IGProjectIndustryInfoService gProjectIndustryInfoService;

    // 添加行业
    @PostMapping("/add")
    public boolean addIndustry(@RequestBody GProjectIndustryInfo industryInfo) {
        return gProjectIndustryInfoService.save(industryInfo);
    }

    // 删除行业
    @DeleteMapping("/delete/{id}")
    public boolean deleteIndustry(@PathVariable Long id) {
        return gProjectIndustryInfoService.removeById(id);
    }

    // 更新行业信息
    @PutMapping("/update")
    public boolean updateIndustry(@RequestBody GProjectIndustryInfo industryInfo) {
        return gProjectIndustryInfoService.updateById(industryInfo);
    }

    // 查询单个行业信息
    @GetMapping("/{id}")
    public GProjectIndustryInfo getIndustry(@PathVariable Long id) {
        return gProjectIndustryInfoService.getById(id);
    }

    // 查询所有行业信息
    @GetMapping("/all")
    public List<GProjectIndustryInfo> getAllIndustries() {
        return gProjectIndustryInfoService.list();
    }

}
